package com.zmm.weblog.admin.controller;

import com.zmm.weblog.admin.model.vo.category.AddCategoryReqVo;
import com.zmm.weblog.admin.model.vo.category.DeleteCategoryReqVo;
import com.zmm.weblog.admin.model.vo.category.FindCategoryPageListReqVo;
import com.zmm.weblog.admin.service.AdminCategoryService;
import com.zmm.weblog.common.aspect.ApiOperationLog;
import com.zmm.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author:福禄寿
 * @Date:2024/4/30 下午4:36
 * @Des:weblog-springboot
 **/
@RestController
@RequestMapping("/admin/category")
@Api(tags = "Admin 分类模块")
public class AdminCategoryController {

    @Autowired
    private AdminCategoryService categoryService;

    @PostMapping("/add")
    @ApiOperation(value = "添加分类")
    @ApiOperationLog(description = "添加分类")
    public Response addCategory(@RequestBody @Validated  AddCategoryReqVo addCategoryReqVo){
        return categoryService.addCategory(addCategoryReqVo);
    }

    @PostMapping("/list")
    @ApiOperation(value = "分类分页数据获取")
    @ApiOperationLog(description = "分类分页数据获取")
    public Response findCategoryPageList(@RequestBody @Validated FindCategoryPageListReqVo pageListReqVo){
        return categoryService.findCategoryPageList(pageListReqVo);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    @ApiOperationLog(description = "删除")
    public Response deleteCategory(@RequestBody @Validated DeleteCategoryReqVo deleteCategoryReqVo){
        return categoryService.deleteCategory(deleteCategoryReqVo);
    }

    @PostMapping("/select/list")
    @ApiOperation(value = "下拉列表框")
    @ApiOperationLog(description = "下拉列表框")
    public Response selectListCategory(){
        return categoryService.selectListCategory();
    }
}
